package com.fenghuo.map;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;

import com.fenghuo.model.MapPoint;
import com.fenghuo.utils.UtilPrefference;
import com.fenghuo.utils.Values;

import net.tsz.afinal.FinalDb;

public class Ac_Welc extends Activity implements AnimationListener {

    private Intent intent;
    private boolean isfirst = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View view = getLayoutInflater().inflate(R.layout.ac_flash, null);
//		requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        AlphaAnimation animation = new AlphaAnimation(0.1f, 1.0f);
        if (UtilPrefference.isfirst(Ac_Welc.this)) {
            animation.setDuration(3000);
            isfirst = true;
        } else {
            animation.setDuration(1500);
        }
        animation.setAnimationListener(this);
        view.setAnimation(animation);
        setContentView(view);
        intent = new Intent(this, Ac_Main.class);
    }

    @Override
    public void onAnimationStart(Animation animation) {
        if (isfirst) {//第一次运行程序

            new Thread(new Runnable() {

                @Override
                public void run() {
                    FinalDb finalDb = FinalDb.create(Ac_Welc.this, Values.DB_NAME);
                    finalDb.save(new MapPoint(0, 130, 190, "公交车站", "公交站", "介绍", ""));
                    finalDb.save(new MapPoint(0, 207, 166, "西北门", "门", "介绍", ""));
                    finalDb.save(new MapPoint(0, 280, 232, "天津市大学软件学院", "", "介绍", ""));
                    finalDb.save(new MapPoint(0, 282, 296, "计算机科学与软件学院", "", "介绍", ""));

                    finalDb.save(new MapPoint(0, 449, 224, "天津市大学生游泳馆", "", "介绍", ""));
                    finalDb.save(new MapPoint(0, 516, 225, "大运广场", "运动场", "介绍", ""));
                    finalDb.save(new MapPoint(0, 594, 226, "天津市大学生体育馆", "", "介绍", ""));
                    finalDb.save(new MapPoint(0, 430, 310, "晨曦园", "", "介绍", ""));
                    finalDb.save(new MapPoint(0, 616, 352, "旭日运动场", "运动场", "介绍", ""));
                    finalDb.save(new MapPoint(0, 565, 450, "工程教学实习训练中心", "", "介绍", ""));
                    finalDb.save(new MapPoint(0, 641, 517, "停车场", "停车场", "介绍", ""));

                    finalDb.save(new MapPoint(0, 147, 381, "软件学院餐厅", "食堂", "介绍", ""));
                    finalDb.save(new MapPoint(0, 155, 407, "ATM", "ATM", "", ""));
                    finalDb.save(new MapPoint(0, 175, 406, "世纪好又多超市", "超市", "介绍", ""));
                    finalDb.save(new MapPoint(0, 140, 464, "软件园公寓", "", "介绍", ""));
                    finalDb.save(new MapPoint(0, 78, 503, "公共厕所", "", "介绍", ""));
                    finalDb.save(new MapPoint(0, 115, 600, "体育场", "运动场", "介绍", ""));
                    finalDb.save(new MapPoint(0, 50, 670, "西大门", "", "介绍", ""));
                    finalDb.save(new MapPoint(0, 285, 625, "人文与法学院", "", "介绍", ""));

                    finalDb.save(new MapPoint(0, 119, 731, "西苑公寓2", "", "介绍", ""));
                    finalDb.save(new MapPoint(0, 266, 726, "馆理学院", "", "介绍", ""));
                    finalDb.save(new MapPoint(0, 236, 767, "求实广场", "运动场", "介绍", ""));
                    finalDb.save(new MapPoint(0, 341, 768, "图书馆", "", "介绍", ""));
                    finalDb.save(new MapPoint(0, 487, 773, "创新广场", "运动场", "介绍", ""));
                    finalDb.save(new MapPoint(0, 574, 705, "艺缘活动中心", "", "介绍", ""));
                    finalDb.save(new MapPoint(0, 679, 667, "东大门", "", "介绍", ""));
                    finalDb.save(new MapPoint(0, 643, 449, "停车场", "停车场", "介绍", ""));
                    finalDb.save(new MapPoint(0, 634, 742, "医院", "医务室", "介绍", ""));

                    finalDb.save(new MapPoint(0, 355, 846, "励志广场", "运动场", "介绍", ""));
                    finalDb.save(new MapPoint(0, 270, 860, "第一公共教学楼", "", "介绍", ""));
                    finalDb.save(new MapPoint(0, 439, 864, "第二公共教学楼", "", "介绍", ""));
                    finalDb.save(new MapPoint(0, 570, 867, "东苑第一食堂", "食堂", "介绍", ""));
                    finalDb.save(new MapPoint(0, 610, 977, "东苑第二食堂", "食堂", "介绍", ""));
                    finalDb.save(new MapPoint(0, 632, 887, "东苑综合服务中心", "", "介绍", ""));

                    finalDb.save(new MapPoint(0, 475, 1009, "奔月运动场", "运动场", "介绍", ""));
                    finalDb.save(new MapPoint(0, 208, 1002, "祥云运动场", "运动场", "介绍", ""));
                    finalDb.save(new MapPoint(0, 187, 881, "ATM", "ATM", "", ""));
                    finalDb.save(new MapPoint(0, 192, 883, "超市", "超市", "介绍", ""));
                    finalDb.save(new MapPoint(0, 120, 1003, "西苑公寓1", "", "介绍", ""));
                    finalDb.save(new MapPoint(0, 364, 1063, "南大门", "", "介绍", ""));
                }
            }).start();

        }
    }

    @Override
    public void onAnimationEnd(Animation animation) {
        startActivity(intent);
        finish();
    }

    @Override
    public void onAnimationRepeat(Animation animation) {

    }


}
